package cn.hgpu.servlet;

import cn.hgpu.mapper.MenuMapper;
import cn.hgpu.pojo.Menu;
import cn.hgpu.utils.MybatisUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 管理员列表
 */
@WebServlet("/menu/list")
public class MenuListServlet extends HttpServlet {

    private MenuMapper menuMapper = MybatisUtils.getMapper(MenuMapper.class);

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //1.查询管理员列表页面
        List<Menu> list = menuMapper.selectAll();

        //2.将数据放到内存中
        req.setAttribute("list1", list);

        //3.跳转到/admin/list.jsp
        req.getRequestDispatcher("/menu/list.jsp").forward(req, resp);
    }
}
